package com.techshine.common.base;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.servlet.ModelAndView;
/**
 * 
 *
 * @Description controller基类
 * @author (作者) liukd
 * @date (开发日期) 2016年10月27日 下午12:19:38 
 * @company (开发公司) 北京精仪达盛科技有限公司
 * @copyright (版权) 本文件归北京精仪达盛科技有限公司所有
 * @version (版本) V1.0
 * @since (该版本支持的JDK版本) ： 1.7
 * @modify (修改) 
 *                  
 *                  
 *                  
 * @Review (审核人)
 */
public class BaseController {
    @SuppressWarnings("unused")
    private static final long serialVersionUID = 6357869213649815390L;
    
    public Logger log = Logger.getLogger(this.getClass());
    
    public HttpServletRequest request;
    
    public HttpServletResponse response;
    
    @ModelAttribute
    public void setAttribute(HttpServletRequest request, HttpServletResponse response) {
        this.request = request;
        this.response = response;
        response.setContentType("application/json; charset=UTF-8");
    }
   
    /**
     * 得到ModelAndView
     */
    public ModelAndView getModelAndView() {
        return new ModelAndView();
    }
    
    /**
     * 得到request对象
     */
    public HttpServletRequest getRequest() {
        HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
        
        return request;
    }
  
    
    public HttpServletResponse getResponse() {
        return response;
    }
    
    public void setResponse(HttpServletResponse response) {
        this.response = response;
    }
    
    public void setRequest(HttpServletRequest request) {
        this.request = request;
    }

    public Logger getLog() {
        return log;
    }

    public void setLog(Logger log) {
        this.log = log;
    }

    
}
